{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0e7182bc",
   "metadata": {},
   "source": [
    "--------\n",
    "* 日期：2022-09-14\\weeko4\n",
    "* 课程：python\n",
    "* 记录人：zhoubilian\n",
    "--------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95c4bd67",
   "metadata": {},
   "source": [
    "### 回顾与复习\n",
    "> for+range()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "02e6ee56",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7aeb1caf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(0, 5)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建有序数值（创建自然数）\n",
    "range(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "0da187cd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 2, 3, 4]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(5))  # 产生了5-0个值，默认从0开始 注：0（start）5（stop）  每一次增长1个单位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a3488926",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(2, 5)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(2,5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "6f04cad2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2, 3, 4]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(2,5)) # 产生了5-2个值，start=2 stop=5 每一次增长1个单位（step）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ad6c658c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(1, 10, 3)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(1,10,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "4c2f09f3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 7]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(1,10,3)) # start=2 stop=5 每一次增长3个单位 steo=3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "7869f4e2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https：//www.nfu.edu.cn./xxyw/index0.htm\n",
      "该次停留 2 秒\n",
      "https：//www.nfu.edu.cn./xxyw/index1.htm\n",
      "该次停留 8 秒\n",
      "https：//www.nfu.edu.cn./xxyw/index2.htm\n",
      "该次停留 6 秒\n",
      "https：//www.nfu.edu.cn./xxyw/index3.htm\n",
      "该次停留 7 秒\n",
      "https：//www.nfu.edu.cn./xxyw/index4.htm\n",
      "该次停留 1 秒\n"
     ]
    }
   ],
   "source": [
    "### 实战练习：快速生成某个网站的所有页码的URL队列\n",
    "南方学院学校要闻=\"https：//www.nfu.edu.cn./xxyw/index\"\n",
    "页面后缀=\".htm\"\n",
    "page=5\n",
    "for i in range(page):\n",
    "    print(南方学院学校要闻+str(i)+页面后缀) # 字符串拼接 \n",
    "    random_num=random.randint(1,10)\n",
    "    print(\"该次停留\",random_num,'秒')\n",
    "    time.sleep(random_num)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "451fa5b8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 总结：for+range for 可以执行循环，range决定了循环体的执行次数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4fbe1af2",
   "metadata": {},
   "source": [
    "# 本周内容\n",
    "\n",
    "> 1. random模块\n",
    ">> 1. random.random():取0-1之间的伪随机数（浮点型）\n",
    ">> 1. random.randint(a,b):生成a-b之间的随机整数（整数）\n",
    ">> 1. random.choice()随机生成一个序列中的值(非空）\n",
    "> 2. time模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "8084d504",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 1. random\n",
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "0eeaa57b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.07537128985603847"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "d5bc016f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function random:\n",
      "\n",
      "random() method of random.Random instance\n",
      "    random() -> x in the interval [0, 1).\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random.random)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "64536d4f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method randint in module random:\n",
      "\n",
      "randint(a, b) method of random.Random instance\n",
      "    Return random integer in range [a, b], including both end points.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "## 2.randint\n",
    "help(random.randint)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "c192c7b0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.randint(1,6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "56c77d46",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "5\n",
      "6\n",
      "1\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(random.randint(1,6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2574058d",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 3.random.choice"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "d99355aa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method choice in module random:\n",
      "\n",
      "choice(seq) method of random.Random instance\n",
      "    Choose a random element from a non-empty sequence.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random.choice)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "5a2e81ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'周碧莲'"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.choice(['潘文静','周碧莲','李圆圆'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3954a99c",
   "metadata": {},
   "source": [
    "## 2.time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "b85ec1ba",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "fcab98a3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sleep in module time:\n",
      "\n",
      "sleep(...)\n",
      "    sleep(seconds)\n",
      "    \n",
      "    Delay execution for a given number of seconds.  The argument may be\n",
      "    a floating point number for subsecond precision.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(time.sleep)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "416f34a2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\n",
      "world\n"
     ]
    }
   ],
   "source": [
    "print(\"hello\")\n",
    "time.sleep(3)\n",
    "print(\"world\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bae14998",
   "metadata": {},
   "source": [
    "# 3.课本实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fb047e5d",
   "metadata": {},
   "outputs": [],
   "source": [
    "### 项目2  P35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "42fbd5ee",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "14\n",
      "现在是秒/时间为偶数\n",
      "等待时间为： 3\n",
      "17\n",
      "现在是秒/时间为奇数\n",
      "等待时间为： 2\n",
      "19\n",
      "现在是秒/时间为奇数\n",
      "等待时间为： 4\n",
      "23\n",
      "现在是秒/时间为奇数\n",
      "等待时间为： 2\n",
      "25\n",
      "现在是秒/时间为奇数\n",
      "等待时间为： 1\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "import time,random\n",
    "\n",
    "odds=[ 1,3,5,7,9,11,13,15,17,19,\n",
    "           21,23,25,27,29,31,33,35,37,39,\n",
    "           41,43,45,47,49,51,53,55,57,59]\n",
    "# right_this_mintue 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "\n",
    "\n",
    "for i in range(5):\n",
    "    right_this_second=datetime.datetime.today().second\n",
    "    if right_this_second in odds:\n",
    "        print(right_this_second)\n",
    "        print(\"现在是秒/时间为奇数\")\n",
    "        \n",
    "    else:\n",
    "        print(right_this_second)\n",
    "        print(\"现在是秒/时间为偶数\")\n",
    "    wait_time=random.randint(1,5)\n",
    "    print(\"等待时间为：\",wait_time)\n",
    "    time.sleep(wait_time)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "5aaacb6c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles 在啤酒墙上\n",
      "99 bottles 啤酒\n",
      "拿一瓶走\n",
      "98 bottles 在啤酒墙上\n",
      "98 bottles 啤酒\n",
      "拿一瓶走\n",
      "97 bottles 在啤酒墙上\n",
      "97 bottles 啤酒\n",
      "拿一瓶走\n",
      "96 bottles 在啤酒墙上\n",
      "96 bottles 啤酒\n",
      "拿一瓶走\n",
      "95 bottles 在啤酒墙上\n",
      "95 bottles 啤酒\n",
      "拿一瓶走\n",
      "94 bottles 在啤酒墙上\n",
      "94 bottles 啤酒\n",
      "拿一瓶走\n",
      "93 bottles 在啤酒墙上\n",
      "93 bottles 啤酒\n",
      "拿一瓶走\n",
      "92 bottles 在啤酒墙上\n",
      "92 bottles 啤酒\n",
      "拿一瓶走\n",
      "91 bottles 在啤酒墙上\n",
      "91 bottles 啤酒\n",
      "拿一瓶走\n",
      "90 bottles 在啤酒墙上\n",
      "90 bottles 啤酒\n",
      "拿一瓶走\n",
      "89 bottles 在啤酒墙上\n",
      "89 bottles 啤酒\n",
      "拿一瓶走\n",
      "88 bottles 在啤酒墙上\n",
      "88 bottles 啤酒\n",
      "拿一瓶走\n",
      "87 bottles 在啤酒墙上\n",
      "87 bottles 啤酒\n",
      "拿一瓶走\n",
      "86 bottles 在啤酒墙上\n",
      "86 bottles 啤酒\n",
      "拿一瓶走\n",
      "85 bottles 在啤酒墙上\n",
      "85 bottles 啤酒\n",
      "拿一瓶走\n",
      "84 bottles 在啤酒墙上\n",
      "84 bottles 啤酒\n",
      "拿一瓶走\n",
      "83 bottles 在啤酒墙上\n",
      "83 bottles 啤酒\n",
      "拿一瓶走\n",
      "82 bottles 在啤酒墙上\n",
      "82 bottles 啤酒\n",
      "拿一瓶走\n",
      "81 bottles 在啤酒墙上\n",
      "81 bottles 啤酒\n",
      "拿一瓶走\n",
      "80 bottles 在啤酒墙上\n",
      "80 bottles 啤酒\n",
      "拿一瓶走\n",
      "79 bottles 在啤酒墙上\n",
      "79 bottles 啤酒\n",
      "拿一瓶走\n",
      "78 bottles 在啤酒墙上\n",
      "78 bottles 啤酒\n",
      "拿一瓶走\n",
      "77 bottles 在啤酒墙上\n",
      "77 bottles 啤酒\n",
      "拿一瓶走\n",
      "76 bottles 在啤酒墙上\n",
      "76 bottles 啤酒\n",
      "拿一瓶走\n",
      "75 bottles 在啤酒墙上\n",
      "75 bottles 啤酒\n",
      "拿一瓶走\n",
      "74 bottles 在啤酒墙上\n",
      "74 bottles 啤酒\n",
      "拿一瓶走\n",
      "73 bottles 在啤酒墙上\n",
      "73 bottles 啤酒\n",
      "拿一瓶走\n",
      "72 bottles 在啤酒墙上\n",
      "72 bottles 啤酒\n",
      "拿一瓶走\n",
      "71 bottles 在啤酒墙上\n",
      "71 bottles 啤酒\n",
      "拿一瓶走\n",
      "70 bottles 在啤酒墙上\n",
      "70 bottles 啤酒\n",
      "拿一瓶走\n",
      "69 bottles 在啤酒墙上\n",
      "69 bottles 啤酒\n",
      "拿一瓶走\n",
      "68 bottles 在啤酒墙上\n",
      "68 bottles 啤酒\n",
      "拿一瓶走\n",
      "67 bottles 在啤酒墙上\n",
      "67 bottles 啤酒\n",
      "拿一瓶走\n",
      "66 bottles 在啤酒墙上\n",
      "66 bottles 啤酒\n",
      "拿一瓶走\n",
      "65 bottles 在啤酒墙上\n",
      "65 bottles 啤酒\n",
      "拿一瓶走\n",
      "64 bottles 在啤酒墙上\n",
      "64 bottles 啤酒\n",
      "拿一瓶走\n",
      "63 bottles 在啤酒墙上\n",
      "63 bottles 啤酒\n",
      "拿一瓶走\n",
      "62 bottles 在啤酒墙上\n",
      "62 bottles 啤酒\n",
      "拿一瓶走\n",
      "61 bottles 在啤酒墙上\n",
      "61 bottles 啤酒\n",
      "拿一瓶走\n",
      "60 bottles 在啤酒墙上\n",
      "60 bottles 啤酒\n",
      "拿一瓶走\n",
      "59 bottles 在啤酒墙上\n",
      "59 bottles 啤酒\n",
      "拿一瓶走\n",
      "58 bottles 在啤酒墙上\n",
      "58 bottles 啤酒\n",
      "拿一瓶走\n",
      "57 bottles 在啤酒墙上\n",
      "57 bottles 啤酒\n",
      "拿一瓶走\n",
      "56 bottles 在啤酒墙上\n",
      "56 bottles 啤酒\n",
      "拿一瓶走\n",
      "55 bottles 在啤酒墙上\n",
      "55 bottles 啤酒\n",
      "拿一瓶走\n",
      "54 bottles 在啤酒墙上\n",
      "54 bottles 啤酒\n",
      "拿一瓶走\n",
      "53 bottles 在啤酒墙上\n",
      "53 bottles 啤酒\n",
      "拿一瓶走\n",
      "52 bottles 在啤酒墙上\n",
      "52 bottles 啤酒\n",
      "拿一瓶走\n",
      "51 bottles 在啤酒墙上\n",
      "51 bottles 啤酒\n",
      "拿一瓶走\n",
      "50 bottles 在啤酒墙上\n",
      "50 bottles 啤酒\n",
      "拿一瓶走\n",
      "49 bottles 在啤酒墙上\n",
      "49 bottles 啤酒\n",
      "拿一瓶走\n",
      "48 bottles 在啤酒墙上\n",
      "48 bottles 啤酒\n",
      "拿一瓶走\n",
      "47 bottles 在啤酒墙上\n",
      "47 bottles 啤酒\n",
      "拿一瓶走\n",
      "46 bottles 在啤酒墙上\n",
      "46 bottles 啤酒\n",
      "拿一瓶走\n",
      "45 bottles 在啤酒墙上\n",
      "45 bottles 啤酒\n",
      "拿一瓶走\n",
      "44 bottles 在啤酒墙上\n",
      "44 bottles 啤酒\n",
      "拿一瓶走\n",
      "43 bottles 在啤酒墙上\n",
      "43 bottles 啤酒\n",
      "拿一瓶走\n",
      "42 bottles 在啤酒墙上\n",
      "42 bottles 啤酒\n",
      "拿一瓶走\n",
      "41 bottles 在啤酒墙上\n",
      "41 bottles 啤酒\n",
      "拿一瓶走\n",
      "40 bottles 在啤酒墙上\n",
      "40 bottles 啤酒\n",
      "拿一瓶走\n",
      "39 bottles 在啤酒墙上\n",
      "39 bottles 啤酒\n",
      "拿一瓶走\n",
      "38 bottles 在啤酒墙上\n",
      "38 bottles 啤酒\n",
      "拿一瓶走\n",
      "37 bottles 在啤酒墙上\n",
      "37 bottles 啤酒\n",
      "拿一瓶走\n",
      "36 bottles 在啤酒墙上\n",
      "36 bottles 啤酒\n",
      "拿一瓶走\n",
      "35 bottles 在啤酒墙上\n",
      "35 bottles 啤酒\n",
      "拿一瓶走\n",
      "34 bottles 在啤酒墙上\n",
      "34 bottles 啤酒\n",
      "拿一瓶走\n",
      "33 bottles 在啤酒墙上\n",
      "33 bottles 啤酒\n",
      "拿一瓶走\n",
      "32 bottles 在啤酒墙上\n",
      "32 bottles 啤酒\n",
      "拿一瓶走\n",
      "31 bottles 在啤酒墙上\n",
      "31 bottles 啤酒\n",
      "拿一瓶走\n",
      "30 bottles 在啤酒墙上\n",
      "30 bottles 啤酒\n",
      "拿一瓶走\n",
      "29 bottles 在啤酒墙上\n",
      "29 bottles 啤酒\n",
      "拿一瓶走\n",
      "28 bottles 在啤酒墙上\n",
      "28 bottles 啤酒\n",
      "拿一瓶走\n",
      "27 bottles 在啤酒墙上\n",
      "27 bottles 啤酒\n",
      "拿一瓶走\n",
      "26 bottles 在啤酒墙上\n",
      "26 bottles 啤酒\n",
      "拿一瓶走\n",
      "25 bottles 在啤酒墙上\n",
      "25 bottles 啤酒\n",
      "拿一瓶走\n",
      "24 bottles 在啤酒墙上\n",
      "24 bottles 啤酒\n",
      "拿一瓶走\n",
      "23 bottles 在啤酒墙上\n",
      "23 bottles 啤酒\n",
      "拿一瓶走\n",
      "22 bottles 在啤酒墙上\n",
      "22 bottles 啤酒\n",
      "拿一瓶走\n",
      "21 bottles 在啤酒墙上\n",
      "21 bottles 啤酒\n",
      "拿一瓶走\n",
      "20 bottles 在啤酒墙上\n",
      "20 bottles 啤酒\n",
      "拿一瓶走\n",
      "19 bottles 在啤酒墙上\n",
      "19 bottles 啤酒\n",
      "拿一瓶走\n",
      "18 bottles 在啤酒墙上\n",
      "18 bottles 啤酒\n",
      "拿一瓶走\n",
      "17 bottles 在啤酒墙上\n",
      "17 bottles 啤酒\n",
      "拿一瓶走\n",
      "16 bottles 在啤酒墙上\n",
      "16 bottles 啤酒\n",
      "拿一瓶走\n",
      "15 bottles 在啤酒墙上\n",
      "15 bottles 啤酒\n",
      "拿一瓶走\n",
      "14 bottles 在啤酒墙上\n",
      "14 bottles 啤酒\n",
      "拿一瓶走\n",
      "13 bottles 在啤酒墙上\n",
      "13 bottles 啤酒\n",
      "拿一瓶走\n",
      "12 bottles 在啤酒墙上\n",
      "12 bottles 啤酒\n",
      "拿一瓶走\n",
      "11 bottles 在啤酒墙上\n",
      "11 bottles 啤酒\n",
      "拿一瓶走\n",
      "10 bottles 在啤酒墙上\n",
      "10 bottles 啤酒\n",
      "拿一瓶走\n",
      "9 bottles 在啤酒墙上\n",
      "9 bottles 啤酒\n",
      "拿一瓶走\n",
      "8 bottles 在啤酒墙上\n",
      "8 bottles 啤酒\n",
      "拿一瓶走\n",
      "7 bottles 在啤酒墙上\n",
      "7 bottles 啤酒\n",
      "拿一瓶走\n",
      "6 bottles 在啤酒墙上\n",
      "6 bottles 啤酒\n",
      "拿一瓶走\n",
      "5 bottles 在啤酒墙上\n",
      "5 bottles 啤酒\n",
      "拿一瓶走\n",
      "4 bottles 在啤酒墙上\n",
      "4 bottles 啤酒\n",
      "拿一瓶走\n",
      "3 bottles 在啤酒墙上\n",
      "3 bottles 啤酒\n",
      "拿一瓶走\n",
      "2 bottles 在啤酒墙上\n",
      "2 bottles 啤酒\n",
      "拿一瓶走\n"
     ]
    },
    {
     "ename": "NameError",
     "evalue": "name 'new_nmu' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [68]\u001b[0m, in \u001b[0;36m<cell line: 5>\u001b[1;34m()\u001b[0m\n\u001b[0;32m     13\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m new_num\u001b[38;5;241m==\u001b[39m\u001b[38;5;241m1\u001b[39m:\n\u001b[0;32m     14\u001b[0m     word\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mbottle\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m---> 15\u001b[0m     \u001b[38;5;28mprint\u001b[39m(\u001b[43mnew_nmu\u001b[49m,word,\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m在啤酒墙上~~~\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m     16\u001b[0m     \u001b[38;5;28mprint\u001b[39m()\n",
      "\u001b[1;31mNameError\u001b[0m: name 'new_nmu' is not defined"
     ]
    }
   ],
   "source": [
    "# 项目3 P44\n",
    "\n",
    "word=\"bottles\"\n",
    "\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num,word,\"在啤酒墙上\")\n",
    "    print(beer_num,word,\"啤酒\")\n",
    "    print(\"拿一瓶走\")\n",
    "    if beer_num==1:\n",
    "        print(\"只剩一瓶了，不能给你了！\")\n",
    "    else:\n",
    "        new_num=beer_num-1\n",
    "        if new_num==1:\n",
    "            word=\"bottle\"\n",
    "            print(new_nmu,word,\"在啤酒墙上~~~\")\n",
    "            print()\n",
    "            \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "293bfcab",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 课后任务：\n",
    "## 思考：什么是（）\n",
    "## 预习：数值，字符串\n",
    "> 1.[Number Types]\n",
    "> 2.[TEXSequence Type]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
